package com.yundashi.floatview;

import android.app.Application;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.BounceInterpolator;

/**
 *
 * @Author     : Aiden
 * @Date       : 2021/01/25 17:45
 * @Description: demo使用代码
 */
public class BaseApplication extends Application {


    private static final String TAG = "FloatWindow";

    @Override
    public void onCreate() {
        super.onCreate();


        View helpView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.floatview_help, null);

        FloatBuilder.with(getApplicationContext())
                .setView(helpView)
                .setWidth(Screen.width, 0.2f) //设置悬浮控件宽高
                .setHeight(Screen.width, 0.2f)
                .setX(Screen.width, 0.8f) //设置控件初始位置
                .setY(Screen.height, 0.3f)
                .setMoveType(MoveType.slide,0,0)
                .setMoveStyle(500, new BounceInterpolator())
                .setOnViewStateListener(mViewStateListener) //监听悬浮控件状态改变
                .setOnPermissionListener(mPermissionListener) //监听权限申请结果
                .setDesktopShow(true) //桌面显示
                .build();
    }



    private OnPermissionListener mPermissionListener = new OnPermissionListener() {
        @Override
        public void onSuccess() {
            Log.d(TAG, "onSuccess");
        }

        @Override
        public void onFail() {
            Log.d(TAG, "onFail");
        }
    };

    private OnViewStateListener mViewStateListener = new OnViewStateListener() {
        @Override
        public void onPositionUpdate(int x, int y) {
            Log.d(TAG, "onPositionUpdate: x=" + x + " y=" + y);
        }

        @Override
        public void onShow() {
            Log.d(TAG, "onShow");
        }

        @Override
        public void onHide() {
            Log.d(TAG, "onHide");
        }

        @Override
        public void onDismiss() {
            Log.d(TAG, "onDismiss");
        }

        @Override
        public void onMoveAnimStart() {
            Log.d(TAG, "onMoveAnimStart");
        }

        @Override
        public void onMoveAnimEnd() {
            Log.d(TAG, "onMoveAnimEnd");
        }

        @Override
        public void onBackToDesktop() {
            Log.d(TAG, "onBackToDesktop");
        }
    };
}
